package de.riceman.simpleGo.view.views.visualizationView;

import de.riceman.simpleGo.main.BitMatrix;



/**
 * @author reismade
 *
 * @version $Revision$
 */
public class RegularNetAdjacencyMatrixFactory extends AbstractAdjacencyMatrixFactory {

	public RegularNetAdjacencyMatrixFactory(int size) {
		this.adjacencyMatrix = this.createAdjacencyMatrix(size);
	}
	
	/**
	 * @see com.riceman.fdg.matrixFactories.AbstractAdjacencyMatrixFactory#createAdjacencyMatrix(int)
	 */
	@Override
	protected BitMatrix createAdjacencyMatrix(int size) {

		BitMatrix adjacencies = new BitMatrix(size*size);
		
		for (int i = 0; i < (size*size); i++) {
			
			if ((i%size) != 0) {
				adjacencies.set(i, i-1, true);
				adjacencies.set(i-1, i, true);
			}
			if ((i%size) != size-1) {
				adjacencies.set(i, i+1, true);
				adjacencies.set(i+1, i, true);
			}
			if (i < size*(size-1)) {
				adjacencies.set(i, i+size, true);
				adjacencies.set(i+size, i, true);
			}
		}
		
		//System.out.println(adjacencies);
		return adjacencies;	
	}



}
